diff options
Diffstat (limited to 'ui/routes/(app)/ch/[channel]/+page.svelte')
| -rw-r--r-- | ui/routes/(app)/ch/[channel]/+page.svelte | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/ui/routes/(app)/ch/[channel]/+page.svelte b/ui/routes/(app)/ch/[channel]/+page.svelte index 8eba709..dbdb507 100644 --- a/ui/routes/(app)/ch/[channel]/+page.svelte +++ b/ui/routes/(app)/ch/[channel]/+page.svelte @@ -18,15 +18,17 @@ const elementTop = elRect.top; const elementBottom = elRect.bottom; - return ((parentTop < elementTop) && (parentBottom > elementBottom)); + return parentTop < elementTop && parentBottom > elementBottom; } function getLastVisibleMessage() { const parentElement = activeChannel; const childElements = parentElement.getElementsByClassName('message'); - const lastInView = Array.from(childElements).reverse().find((el) => { - return inView(parentElement, el); - }); + const lastInView = Array.from(childElements) + .reverse() + .find((el) => { + return inView(parentElement, el); + }); return lastInView; } @@ -50,14 +52,14 @@ }); function handleKeydown(event) { - if (event.key === 'Escape') { + if (event.key === 'Escape') { setLastRead(); // TODO: pass in "last message DT"? } } let lastReadCallback = null; function handleScroll() { - clearTimeout(lastReadCallback); // Fine if lastReadCallback is null still. + clearTimeout(lastReadCallback); // Fine if lastReadCallback is null still. lastReadCallback = setTimeout(setLastRead, 2 * 1000); } </script> |
